/**
 * Copyright © 2017 陈锦韬  All rights reserved.
 * 
 * @Package: com.application.config 
 * @author: Administrator   
 * @date: 2017年12月25日 下午2:25:59
 */
package com.application.config;

import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import com.application.common.BaseLogger;
import com.application.iface.IConfigure;
import com.application.iface.IDispatcher;
import com.application.iface.IMessage;
import com.application.iface.IPacket;


/**
 * @className: ConfigService 
 * @author: Administrator
 * @Description: TODO
 * @date: 2017年12月25日 下午2:25:59
 */
public class ConfigService implements IConfigure {
    private String serviceId;
    private String dispatcherName;
    private ThreadPoolTaskExecutor taskExec;
    private IDispatcher disptcher;
	public String getServiceId() {
		return serviceId;
	}
	public void setServiceId(String serviceId) {
		this.serviceId = serviceId;
	}
	public String getDispatcherName() {
		return dispatcherName;
	}
	public void setDispatcherName(String dispatcherName) {
		this.dispatcherName = dispatcherName;
	}
	public ThreadPoolTaskExecutor getTaskExec() {
		return taskExec;
	}
	public void setTaskExec(ThreadPoolTaskExecutor taskExec) {
		this.taskExec = taskExec;
	}
	public IDispatcher getDisptcher() {
		return disptcher;
	}
	public void setDisptcher(IDispatcher disptcher) {
		this.disptcher = disptcher;
	}
    
	// 加入线程池
	public void doStart(IPacket pack,IMessage msg){
		try{
			taskExec.submit(ConfigService.ExecTask(pack,msg,this));
		}catch (Throwable t){
			BaseLogger.writeLog("E", "提交线程池失败");
		}		
	}

	public static Runnable ExecTask(final IPacket pack,final IMessage msg,final ConfigService cs){
		Runnable r = new Runnable(){

			public void run() {
               // cs.getDisptcher().dispatch(pack,msg);				
			}
			
		};
		return r;
	}
}
